﻿#include "stdafx.h"
#include "DkActionBlood.h"
#include "PressKeyUtil.h"
#include "DefInfo/GameInfo.h"
#include "DefInfo/Team_Raid_Info.h"

DkActionBlood::DkActionBlood()
{
}


DkActionBlood::~DkActionBlood()
{
}

void DkActionBlood::ChooseBattleAction()
{
	if (PressKeyUtil::inst().press_battle_enbale && GameInfo::inst().PlayerInBattle() && GameInfo::inst().TargetIsEnemy() && GameInfo::inst().GetTargetHp() != 0)
	{
		do
		{
			int loss_percent = (int)(GameInfo::inst().GetPlayer().LostHpPecent()*100.0f);
			// 灵界打击
			if (GameInfo::inst().IsActionNotCDAndInRange(Death_Strike))
			{
				if (GameInfo::inst().GetPlayerMana() >= 40)
				{
					if (loss_percent >= 30)
					{
						PressKeyUtil::inst().SendKeyBySpellID(Death_Strike);
						break;
					}
				}
			}
			// 打断施法,心灵冰冻
			if (GameInfo::inst().IsActionNotCDAndInRange(Mind_Freeze))
			{
				if (GameInfo::inst().GetTargetSpellCanInterupt())
				{
					PressKeyUtil::inst().SendKeyBySpellID(Mind_Freeze);
					break;
				}
			}
			// 8. 符文刃舞 8	3.00	dancing_rune_weapon,if=!talent.blooddrinker.enabled|!cooldown.blooddrinker.ready
			if (GameInfo::inst().IsActionNotCDAndInRange(Dancing_Rune_Weapon))
			{
				PressKeyUtil::inst().SendKeyBySpellID(Dancing_Rune_Weapon);
				break;
			}


			// A	23.36	death_strike,if=runic_power.deficit<=10
			if (GameInfo::inst().IsActionNotCDAndInRange(Death_Strike) && GameInfo::inst().GetPlayerMana() >= 45)
			{
				if (GameInfo::inst().GetRunicPowerDeficit() <= 10)
				{
					PressKeyUtil::inst().SendKeyBySpellID(Death_Strike);
					break;
				}
			}

			// B	1.26 marrowrend,if=(buff.bone_shield.remains<=rune.time_to_3 意思是剩余时间 少于 到三个符文的时间
			//|buff.bone_shield.remains<=(gcd+cooldown.blooddrinker.ready*talent.blooddrinker.enabled*2)
			//|buff.bone_shield.stack<3)
			// &runic_power.deficit>=20
			if (GameInfo::inst().IsActionNotCDAndInRange(Marrowrend) && GameInfo::inst().GetRunicPowerDeficit() >= 20 && GameInfo::inst().GetRuneReadyCount() >= 2)
			{
				if (GameInfo::inst().GetPlayerBuffRemainTime(Bone_Shield) <= GameInfo::inst().RuneTimeTo(3))
				{
					PressKeyUtil::inst().SendKeyBySpellID(Marrowrend);
					break;
				}
				if (GameInfo::inst().GetPlayerBuffStack(Bone_Shield) < 3)
				{
					PressKeyUtil::inst().SendKeyBySpellID(Marrowrend);
					break;
				}
				if (GameInfo::inst().GetPlayerBuffRemainTime(Bone_Shield) <= GameInfo::inst().GetGlobalCDExecute())
				{
					PressKeyUtil::inst().SendKeyBySpellID(Marrowrend);
					break;
				}
			}
			// C	3.40 blood_boil,if=charges_fractional>=1.8
			// &(buff.hemostasis.stack<=(5-spell_targets.blood_boil) 這一句的意思是, 如果 释放目标大于等于剩余叠加层数, 则释放.
			// |spell_targets.blood_boil>2) // 这一句 是 释放目标大于2,及3个人 则释放
			if (GameInfo::inst().GetActionCDBySpellId(Blood_Boil) == 0)
			{
				if (GameInfo::inst().GetActionChargeFraction(Blood_Boil) >= 1.8f)
				{
					if (GameInfo::inst().GetPlayerBuffStack(Hemostasis_buff) < (5 - 1))
					{
						PressKeyUtil::inst().SendKeyBySpellID(Blood_Boil);
						break;
					}
				}
			}
			//D	20.98	marrowrend,if=buff.bone_shield.stack<5&talent.ossuary.enabled&runic_power.deficit>=15
			if (GameInfo::inst().IsActionNotCDAndInRange(Marrowrend) && GameInfo::inst().GetPlayerBuffStack(Bone_Shield) < 5 && GameInfo::inst().GetRuneReadyCount() >= 2)
			{
				if (GameInfo::inst().GetRunicPowerDeficit() >= 15)
				{
					PressKeyUtil::inst().SendKeyBySpellID(Marrowrend);
					break;
				}
			}
			//E	16.85	death_strike,if=
			//runic_power.deficit<=(15+buff.dancing_rune_weapon.up*5+spell_targets.heart_strike*talent.heartbreaker.enabled*2)
			// |target.time_to_die<10
			if (GameInfo::inst().IsActionNotCDAndInRange(Death_Strike) && GameInfo::inst().GetPlayerMana() >= 45)
			{
				int power = 15;
				if (GameInfo::inst().GetPlayerBuffUp(Dancing_Rune_Weapon_buff) == 1)
				{
					power += 1 * 5;
				}
				power += 2;
				if (GameInfo::inst().GetRunicPowerDeficit() < (power))
				{
					PressKeyUtil::inst().SendKeyBySpellID(Death_Strike);
					break;
				}
			}
			// F	22.42	heart_strike,if=buff.dancing_rune_weapon.up|rune.time_to_4<gcd
			if (GameInfo::inst().IsActionNotCDAndInRange(Heart_Strike) && GameInfo::inst().GetRuneReadyCount() >= 1)
			{
				if (GameInfo::inst().GetPlayerBuffRemainTime(Dancing_Rune_Weapon_buff) == 0)
				{
					PressKeyUtil::inst().SendKeyBySpellID(Heart_Strike);
					break;
				}
				if (GameInfo::inst().RuneTimeTo(4) < GameInfo::inst().GetGlobalCDExecute())
				{
					PressKeyUtil::inst().SendKeyBySpellID(Heart_Strike);
					break;
				}
			}
			//G	0.61	blood_boil,if=buff.dancing_rune_weapon.up
			if (GameInfo::inst().GetActionCDBySpellId(Blood_Boil) == 0)
			{
				if (GameInfo::inst().GetPlayerBuffUp(Dancing_Rune_Weapon_buff) == 1)
				{
					PressKeyUtil::inst().SendKeyBySpellID(Blood_Boil);
					break;
				}
			}
			// H	14.48	death_and_decay,if=buff.crimson_scourge.up|talent.rapid_decomposition.enabled|spell_targets.death_and_decay>=2
			if (GameInfo::inst().GetActionCDBySpellId(Death_and_Decay) == 0 && GameInfo::inst().GetRuneReadyCount() >= 1)
			{
				if (GameInfo::inst().GetPlayerBuffUp(Crimson_Scourge_Buff) == 1)
				{
					PressKeyUtil::inst().SendKey(VK_NUMPAD1);
					break;
				}
			}
			//I	46.07	blood_boil
			if (GameInfo::inst().GetActionCDBySpellId(Blood_Boil) == 0)
			{
				PressKeyUtil::inst().SendKeyBySpellID(Blood_Boil);
				break;
			}
			// J	46.11	heart_strike,if=rune.time_to_3<gcd|buff.bone_shield.stack>6
			if (GameInfo::inst().IsActionNotCDAndInRange(Heart_Strike) && GameInfo::inst().GetRuneReadyCount() >= 1)
			{
				if (GameInfo::inst().RuneTimeTo(3) < GameInfo::inst().GetGlobalCDExecute())
				{
					PressKeyUtil::inst().SendKeyBySpellID(Heart_Strike);
					break;
				}
				if (GameInfo::inst().GetPlayerBuffStack(Bone_Shield) > 6)
				{
					PressKeyUtil::inst().SendKeyBySpellID(Heart_Strike);
					break;
				}
			}
			// 灵界打击
			if (GameInfo::inst().IsActionNotCDAndInRange(Death_Strike))
			{
				if (GameInfo::inst().GetPlayerMana() >= 65 && loss_percent > 0)
				{
					PressKeyUtil::inst().SendKeyBySpellID(Death_Strike);
					break;
				}
				if (GameInfo::inst().GetRunicPowerDeficit() <= 10)
				{
					PressKeyUtil::inst().SendKeyBySpellID(Death_Strike);
					break;
				}
				if (GameInfo::inst().GetPlayerMana() >= 85)
				{
					PressKeyUtil::inst().SendKeyBySpellID(Death_Strike);
					break;
				}
			}
			//
			if (GameInfo::inst().IsActionNotCDAndInRange(Heart_Strike) && GameInfo::inst().GetRuneReadyCount() >= 5 && GameInfo::inst().RuneTimeTo(6) <= 10)
			{
				PressKeyUtil::inst().SendKeyBySpellID(Death_Strike);
				break;
			}
		} while (false);
	}

}
